<?php
/**
 * Created by PhpStorm.
 * User: hp
 * Date: 2019/2/25
 * Time: 16:53
 */

namespace App\Http\Controllers\Company;


use App\Http\Controllers\BaseApiController;
use App\Services\Company\CompanyService;
use Illuminate\Http\Request;
use Validator;

class CompanyController extends BaseApiController
{
    private $service;

    public function __construct(CompanyService $service)
    {
        //继承基类的构造方法
        parent::__construct();
        //依赖注入service
        $this->service=$service;
    }

    /**
     * @param Request $request
     * @return mixed
     * 公司详情
     */
    public function companyShow(Request $request)
    {
        $data['id'] = $request->input('id');
        $rule = $this->idFind($data);
        if ($rule->fails()){
            return $rule->errors();
        }
        $res = $this->service->companyShow($data['id']);
        return $res;
    }

    //公司编辑资料
    public function companyUpd(Request $request){
        $name=$request->input('name');
        $address=$request->input('address');
        $credit_code=$request->input('credit_code');
        $email=$request->input('email');
        $guimo=$request->input('guimo');
        $id=$request->input('id');
        $image=$request->input('image');
        $industry_id=$request->input('industry_id');
        $tag=$request->input('tag');
        $res=$this->service->companyUpd($name,$address,$credit_code,$email,$guimo,$id,$image,$industry_id,$tag);
        return $res;
    }

}